package com.zhou.base.resilience4j.test.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;


/**
 * 使用了knife4j
 * 日志地址：http://localhost:port/context-path/doc.html
 */
@Configuration
@EnableSwagger2WebMvc
public class Swagger2Config {


    @Value("${swagger.enable:false}")
    private boolean swaggerEnable;

   public static Contact contact = new Contact("zxf", "https://digitalcnzz.yuque.com/kzugk4/stoklv/tyg6in","");

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
               // .enable(swaggerEnable)
                .apiInfo(apiInfo())
                .groupName("1版本")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.zhou.base.resilience4j.test.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("码农计划")
                .description("码农计划")
                .contact(contact)
                .version("1.0")
                .build();
    }
}
